{extend name="public:_base" /}
{block name="css"}
{CSS href="__STATIC__/w/layui.css" /}
{CSS href="__STATIC__/w/layui-admin.css" /}
<link rel="stylesheet" type="text/css" href="__STATIC__/admin/css/treemenu.css"/>
<style type="text/css">
    input[type="checkbox"] {
        zoom: 130%;
        margin-top: 0px;
    }

    .w40x {
        width: 20px;
        height: 18px;
        float: left;
        position: relative;
        margin-right: 5px;
    }
    .w40xc {
        margin-right: 25px;
    }
    .w40x:before {
        content: '';
        position: absolute;
        top: -15px;
        left: 50%;
        width: 1px;
        height: 24px;
        background: #ccc;
    }
    .w40x:after {
        content: '';
        position: absolute;
        top: 50%;
        left: 50%;
        width: 50%;
        height: 1px;
        background: #ccc;
    }
    .w40xc:after {
        width: 150%;
    }
    #treet1 tr:hover {
        background: #d6d6d6;
    }
</style>
{/block}

{block name="main"}

<div class="page-container">
        <div class="Huialert Huialert-info">
            <i class="Hui-iconfont">&#xe6a6;</i>
            <h4 title="提示相关设置操作时应注意的要点">操作提示</h4>
            <ul>
                <li>新增，修改，删除之后请“清理缓存”</li>
            </ul>
        </div>
    <div class="cl pd-5 bg-1 bk-gray">
        <span class="l">
            <a class="btn radius btn-primary" onclick="edit('添加模块','{:url('Nav/edit',['type'=>'model'])}')" href="javascript:;">
                <i class="Hui-iconfont">&#xe600;</i> 添加栏目
            </a>

            <a class="btn radius btn-primary" onclick="edit('添加单页面','{:url('Nav/edit',['type'=>'one'])}')" href="javascript:;">
                <i class="Hui-iconfont">&#xe600;</i> 添加单页面
            </a>

            <a class="btn radius btn-primary" onclick="edit('添加外部链接','{:url('Nav/edit',['type'=>'link'])}')" href="javascript:;">
                <i class="Hui-iconfont">&#xe600;</i> 添加外部链接
            </a>
        </span>

    </div>

    <form method="post">
        <div class="flexigrid">
            <div class="mDiv">
                <div class="ftitle">
                    <h3>栏目列表(共{$arctype_list|count}条记录)</h3>
                </div>
            </div>

            <div id="flexigrid" class="bDiv" style="height: auto;">
                {empty name="arctype_list"}
                <div id="flexigrid" cellpadding="0" cellspacing="0" border="0">
                    <table>
                        <tbody>
                        <tr>
                            <td class="no-data" align="center" axis="col0" colspan="50">
                                <i class="fa fa-exclamation-circle"></i>没有符合条件的记录
                            </td>
                        </tr>
                        </tbody>
                    </table>
                </div>
                <div class="iDiv" style="display: none;"></div>
                {else /}
                <table class="table table-border table-bg" cellpadding="0" cellspacing="0" border="0" id="arctype_table" style="width: 100%">
                    <thead>
                    <tr>
                        <th axis="col3" class="w60">
                            <div class="sundefined tc">ID</div>
                        </th>
                        <th axis="col3" class="">
                            <div class="sundefined" >
                                <img src="__STATIC__/admin/images/tv-expandable.gif" id="all_treeclicked" title="关闭所有子栏目" style="float: none;" data-status="close" onClick="treeClicked(this,'all',0);">
                                栏目名称
                            </div>
                        </th>
                        <th axis="col2" class="w100">
                            <div class="tc">所属模型</div>
                        </th>
                        <th axis="col2" class="w60">
                            <div>隐藏</div>
                        </th>
                        <th axis="col1" class="w300">
                            <div class="tl" style="text-indent: 6px">操作</div>
                        </th>
                        <th axis="col2" class="w60">
                            <div class="tc">排序</div>
                        </th>
                    </tr>
                    </thead>
                    <tbody id="treet1">
                    {foreach name="arctype_list" item="vo" key="k" }
                    <tr nctype="0" {if condition="$vo['pid'] gt 0"} style="display:none;"{/if} class="pid_{$vo['pid']}" data-level="{$vo['level']}" data-id="{$vo['id']}">
                    <td class="name">
                        <div class="w60 tc">
                            {$vo.id}
                        </div>
                    </td>
                    <td class="name" style="width: 40%">
                        <div>
                            {gt name='vo.level' value='0'}
                            {php}
                            if (1 == $vo['level']) {
                            echo '<span class="w40x"></span>';
                            } elseif (2 == $vo['level']) {
                            echo '<span class="w40x w40xc"></span>';
                            }
                            {/php}
                            {/gt}

                            {gt name="vo.has_children" value="0"}
                            <img src="__STATIC__/admin/images/tv-expandable.gif" style="float: none;" fieldid="2" status="open" nc_type="flex" onClick="treeClicked(this,{$vo['id']},0);" class="has_children">
                            {else /}
                            <img src="__STATIC__/admin/images/tv-collapsable-last.gif" style="float: none;" fieldid="2" status="open" nc_type="flex">
                            {/gt}

                            {$vo.name}
                            {if condition="($vo.type eq 'model') and ($vo.model neq 'index') and ($vo.model neq 'Index')"}
                            <i class="arctotal">（文档：{$vo.id|get_total_arc=###,$vo.model}条）</i>
                            {elseif condition="($vo.type eq 'one')"}
                                {notempty name="$vo.id|get_total_massage"}
                                <a data-title="留言信息" href="{:url('massage/index',['status'=>0,'cid'=>$vo.id])}" onclick="Hui_admin_tab(this)" href="javascript:;"><i class="arctotal">（留言：{$vo.id|get_total_massage}条）</i></a>
                                {/notempty}
                            {/if}
                        </div>
                    </td>
                    <td class="sort">
                        <div class="w100 tc">
                            {notempty name="$nav_model[$vo.model]"}
                            {$nav_model[$vo.model]??''}
                            {else}
                            <span class="{$vo.model}"><font color="#FF0000">外部链接</font></span>
                            {/notempty}
                        </div>
                    </td>

                    <td align="center" class="">
                        <div class="w60">
                            {$vo.status|status=$vo.id}
                        </div>
                    </td>
                    <td>
                        <div class="w300 tl pb0">
                            {if condition="$vo['type'] eq 'model'" /}

                                {eq name="$vo.model" value="index"}
                                <!-- <a href="{:url(\'index/'.$vo.model.'/index',['navid'=>$vo.id])}" class="btn radius blue"  target="_blank">查看</a> -->
                                <a href="{$Request.domain}" class="btn radius blue"  target="_blank">查看</a>
                                {else/}
                                <!-- 测试  <div class="layui-table-cell laytable-cell-1-0-10" style="    padding: 0px;padding-right: 5px;float: left;" > 
                                        <button type="button" class="btn radius btn-primary" onclick="dropdown(this)">操作 <span class="caret"></span></button> 
                                        <ul class="layui-nav-child layui-anim layui-anim-upbit"> 
                                            <li><a class="btn radius btn-primary"  data-title="查看-{$vo.name}" onclick="Hui_admin_tab(this)" href="{:url($vo['model'].'/index',['cid'=>$vo.id])}" href="javascript:;">内容</a></li> 
                                            <li><a class="btn radius btn-primary label-success"  data-title="发布-{$vo.name}" onclick="edit('添加','{:url(\''.$vo.model.'/add',['addcid'=>$vo.id])}')" href="javascript:;">添加</a></li>  
                                        </ul> 
                                    </div> -->


                                    <span class="dropDown dropDown_hover __web-inspector-hide-shortcut__ news-dropDown">
                                        <button class="btn radius btn-primary" type="button" name="move" data-toggle="dropdown" aria-expanded="false">
                                            操作
                                            <!-- <i class="Hui-iconfont">&#xe6d5;</i> -->
                                        </button>
                                
                                        <ul class="dropDown-menu menu radius box-shadow">
                                                <a class="btn radius btn-primary"  data-title="查看-{$vo.name}" onclick="Hui_admin_tab(this)" href="{:url($vo['model'].'/index',['cid'=>$vo.id])}" href="javascript:;">列表</a>
                                                <a class="btn radius btn-success"  data-title="添加-{$vo.name}" onclick="Hui_admin_tab(this)" href="{:url(\''.$vo.model.'/add',['addcid'=>$vo.id])}" href="javascript:;">添加</a>
                                        </ul>
                                    </span>

                                <a style="display:none" href="{:url($vo['model'].'/index',['cid'=>$vo.id])}" class="btn radius btn-primary"  data-title="发布-{$vo.name}" onclick="Hui_admin_tab(this)" href="javascript:;">内容</a>
                                {/eq}

                            {elseif condition="$vo['type'] eq 'one'"/}
                                {empty name="$vo.link"}
                                    <a href="{:url(\'index/'.$vo.model.'/index',['navid'=>$vo.id])}" class="btn radius blue"  target="_blank">查看</a>
                                {else/}
                                    <a href="{$vo['link']|nav_link}" class="btn radius blue"  target="_blank">查看</a>
                                {/empty}
                            {else /}
                                <a href="{$vo['link']}" class="btn radius blue"  target="_blank">查看</a>
                            {/if}

                            <a 11href="{:url('Nav/edit',['type'=>$vo.type,'id'=>$vo.id])}" class="btn radius btn-xs btn-warning" onClick="edit('{$vo.name}编辑','{:url('Nav/edit',['type'=>$vo.type,'id'=>$vo.id])}','10001')" href="javascript:;">编辑</a>

                            <a class="btn radius btn-xs btn-danger"  href="javascript:void(0);" data-url="{:url('Nav/del',['model'=>$vo.model])}" data-id="{$vo.id}" data-name="{$vo.name}" data-deltype="pseudo" onClick="delfun(this);"><i class="fa fa-trash-o"></i>删除</a>

                            {eq name="$vo.type" value="link"}
                                <a href="{$vo.link}" class="btn radius blue" target="_blank">浏览</a>
                            {else/}
                                <a href="{notempty name="$vo.link"}{$vo.link|nav_link} {else/}{:url(\'index/'.$vo['model'].'/index', ['navid' => $vo['id']])}{/notempty}" class="btn radius blue" target="_blank">浏览</a>
                            {/eq}
                        </div>
                        
                        <div class="layui-table-cell laytable-cell-1-0-10" style="display: none"> 
                            <button type="button" class="layui-btn layui-btn-xs btn-success" onclick="$eb.createModalFrame('无线吸尘器F8 玫瑰金礼盒版-属性','/index.php/admin/store.store_product/attr.html?id=1',{h:600,w:800})"> 属性 </button> 
                            <button type="button" class="layui-btn layui-btn-xs layui-btn-normal" onclick="$eb.createModalFrame('无线吸尘器F8 玫瑰金礼盒版-编辑','/index.php/admin/store.store_product/edit.html?id=1',{h:700,w:1100})"> 编辑 </button> 
                            <button type="button" class="layui-btn layui-btn-xs" onclick="dropdown(this)">操作 <span class="caret"></span></button> 
                            <ul class="layui-nav-child layui-anim layui-anim-upbit" style="padding: 10px; top: 22px; min-width: inherit; position: absolute; display: none;"> 
                                <li> <a href="javascript:void(0);" class="" onclick="$eb.createModalFrame(this.innerText,'/index.php/admin/store.store_product/edit_content.html?id=1')"> <i class="fa fa-pencil"></i> 产品详情</a> </li> 
                                <li> <a href="javascript:void(0);" onclick="edit('添加单页面','{:url('Nav/edit',['type'=>'one'])}')"> <i class="fa fa-gavel"></i> 开启秒杀</a> </li>
                                <li> <a href="javascript:void(0);" onclick="$eb.createModalFrame(this.innerText,'/index.php/admin/ump.store_bargain/bargain.html?id=1')"> <i class="fa fa-sort-amount-asc"></i> 开启砍价</a> </li> 
                                <li> <a href="javascript:void(0);" onclick="$eb.createModalFrame(this.innerText,'/index.php/admin/ump.store_combination/combination.html?id=1')"> <i class="fa fa-hand-lizard-o"></i> 开启拼团</a> </li>  
                                <li> <a href="javascript:void(0);" lay-event="delstor"> <i class="fa fa-trash"></i> 移到回收站 </a> </li>  
                                <li> <a href="/index.php/admin/store.store_product_reply/index.html?product_id=1"> <i class="fa fa-warning"></i> 评论查看 </a> </li> 
                            </ul> 
                        </div>
                    </td>
                    <td class="sort">
                        <div class="w60 tc pb0">
                            {$vo.sort|sortby=$vo.id}
                        </div>
                    </td>

                    </tr>
                    {/foreach}
                    </tbody>
                </table>
                {/empty}
            </div>
        </div>
    </form>
    <script type="text/javascript">

        $(document).ready(function(){
            // 表格行点击选中切换
            $('#flexigrid > table>tbody >tr').click(function(){
                $(this).toggleClass('trSelected');
            });

            // 点击刷新数据
            $('.fa-refresh').click(function(){
                location.href = location.href;
            });

            treeClicked($('#all_treeclicked'), 'all', 1);
        });

        // 点击展开 收缩节点
        function treeClicked(obj,id,reload){
            if (id == 'all') {
                if (1 == reload) {
                    var status = getCookie('admin-treeClicked');
                    if (!status) {
                        status = $(obj).attr('data-status');
                    }
                } else {
                    var status = $(obj).attr('data-status');
                }
                if (status == 'close') {
                    $('tr[class^=pid_]').show().find('img').attr('src', '__STATIC__/admin/images/tv-collapsable-last.gif');
                    $(obj).attr('data-status', 'open').attr('title','关闭所有子栏目').attr('src','__STATIC__/admin/images/tv-collapsable-last.gif');
                } else {
                    $('tr[data-level=0]').find('img.has_children').attr('src', '__STATIC__/admin/images/tv-collapsable-last.gif').trigger('click');
                    $('tr[class^=pid_]').removeClass('trSelected');
                    $(obj).attr('data-status', 'close').attr('title','展开所有子栏目').attr('src','__STATIC__/admin/images/tv-expandable.gif');
                }

                setCookies('admin-treeClicked', status);
                return false;
            }
            function setCookies(name, value, time)
            {
                var cookieString = name + "=" + escape(value) + ";";
                if (time != 0) {
                    var Times = new Date();
                    Times.setTime(Times.getTime() + time);
                    cookieString += "expires="+Times.toGMTString()+";"
                }
                document.cookie = cookieString+"path=/";
            }
            var src = $(obj).attr('src');
            if(src == '__STATIC__/admin/images/tv-expandable.gif')
            {
                // $("#treet1 tr").removeClass('tb_child');
                // $(".pid_"+id).addClass('tb_child');
                $(".pid_"+id).show();
                $(obj).attr('src','__STATIC__/admin/images/tv-collapsable-last.gif');
                var status = 'close';
            }else{
                $(obj).attr('src','__STATIC__/admin/images/tv-expandable.gif');
                var status = 'open';

                // 如果是点击减号, 遍历循环他下面的所有都关闭
                var tbl = document.getElementById("arctype_table");
                cur_tr = obj.parentNode.parentNode.parentNode;
                var fnd = false;
                for (i = 0; i < tbl.rows.length; i++)
                {
                    var row = tbl.rows[i];

                    if (row == cur_tr)
                    {
                        fnd = true;
                    }
                    else
                    {
                        if (fnd == true)
                        {

                            var level = parseInt($(row).data('level'));
                            var cur_level = $(cur_tr).data('level');

                            if (level > cur_level)
                            {
                                $(row).hide();
                                $(row).find('img.has_children').attr('src','__STATIC__/admin/images/tv-expandable.gif');
                            }
                            else
                            {
                                fnd = false;
                                break;
                            }
                        }
                    }
                }
            }
            setCookies('admin-treeClicked', status);
        }


        function delfun(obj){
            var title = $(obj).attr('data-name');
            layer.confirm('<font color="#ff0000">如有子栏目及文档将一起清空</font>，确认删除？', {
                title: title,
                btn: ['确定','取消'] //按钮
            }, function(){
                // 确定
                $.ajax({
                    type : 'post',
                    url : $(obj).attr('data-url'),
                    data : {id:$(obj).attr('data-id')},
                    dataType : 'json',
                    success : function(data){
                        layer.closeAll();
                        if(data.status == 1){
                            layer.msg(data.msg, {icon: 1});

                            window.location.reload();
                            //$('tr[data-id="'+$(obj).attr('data-id')+'"]').remove();
                        }else{
                            layer.alert(data.msg, {icon: 2});  //alert(data);
                        }
                    }
                })
            }, function(index){
                layer.close(index);
            });
            return false;
        }
    </script>
    <script>

//下拉框

        function dropdown(that){
            var oEvent = arguments.callee.caller.arguments[0] || event;
            oEvent.stopPropagation();
            var offset = $(that).offset();
            var top=offset.top-$(window).scrollTop();
            var index = $(that).parents('tr').data('index');
            $('.layui-nav-child').each(function (key) {
                if (key != index) {
                    $(this).hide();
                }
            })
            if($(document).height() < top+$(that).next('ul').height()){
                $(that).next('ul').css({
                    'padding': 10,
                    'top': - ($(that).parent('td').height() / 2 + $(that).height() + $(that).next('ul').height()/2),
                    'min-width': 'inherit',
                    'position': 'absolute'
                }).toggle();
            }else{
                $(that).next('ul').css({
                    'padding': 10,
                    'top':$(that).parent('td').height() / 2 + $(that).height(),
                    'min-width': 'inherit',
                    'position': 'absolute'
                }).toggle();
            }
        }
    </script>
</div>






{/block}
{block name="js"}

<script type="text/javascript">
/*
    {volist name="nav_model" id="vv"}
    $(".{$key}").html("{$vv}");
    {/volist}
*/
    $(".about").html("<font color=\"#FF0000\">单页面</font>");

        function tijiao(url, id,status,obj) {
            if($(obj).hasClass('label-danger')){
                $(obj).html("恢复");
                $(obj).removeClass('label-danger').addClass('label-success');
                url= '{:url(\''.\\think\\Request::instance()->controller().'/forbid')}';
            }else {
                $(obj).removeClass('label-success').addClass('label-danger');
                $(obj).html("禁用");
                url= '{:url(\''.\\think\\Request::instance()->controller().'/resume')}';
            }
            $.post(url, {id: id}, function (data) {
                //没有权限返回信息
                if(data.code=='0'){
                    layer.alert(data.msg);
                }
            }, 'json')
        }
</script>
{/block}